brack = list(input('введите скобочную последовательность: '))
stack = []
ans = True


for k in brack:

    if k == '(':
        stack.append(k)
    elif k == '[':
        stack.append(k)
    elif k == '{':
        stack.append(k)
    elif k == '<':
        stack.append(k)

    elif stack != [] and (k == ')' and stack[-1] == '('):
        stack.pop()
    elif stack != [] and (k == ']' and stack[-1] == '['):
        stack.pop()
    elif stack != [] and (k == '}' and stack[-1] == '{'):
        stack.pop()
    elif stack != [] and (k == '>' and stack[-1] == '<'):
        stack.pop()

    elif stack == [] and (k == ')'):
        ans = False
    elif stack == [] and (k == ']'):
        ans = False
    elif stack == [] and (k == '}'):
        ans = False
    elif stack == [] and (k == '>'):
        ans = False


print(ans)